<!DOCTYPE html>
<html lang="en">
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('登录日志列表')" />
</head>
<body class="gray_bg">
    <div class="container-div">
        <div class="btn-group-sm" id="toolbar">
            <a class="btn btn-success" onclick="$.operate.add()" >
                <i class="fa fa-plus"></i> 新增
            </a>
        </div>
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <p class="select-title">普通条件查询</p>
                <form id="ordinary-form">
                    <div class="select-list">
                        <ul>
                            <li>
                                书本名字：<input type="text" name="name"/>
                            </li>
                            <li>
                                作者：<input type="text" name="author"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
        <div class="row">
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>

</body>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    console.log("test1112")
    var prefix = ctx + "book/manage";
    $(function(){

            var options = {
                modalName:"书本",

                url:prefix +"/list",
                createUrl:prefix+"/add",
                updateUrl:prefix+"/update/{id}",
                removeUrl:prefix+"/remove/{id}",
                uniqueId:"id",
                columns:[
                {
                checkbox:true
                },
                {
                        field:"id",
                        title:"id"
                    },
                    {
                        field:"name",
                        title:"名字222"
                    },
                    {
                        field:"author",
                        title:"作者"
                    },
                    {
                        field:"category",
                        title:"分类"
                    },
                    {
                        field:"status",
                        title:"状态"
                    },
                    {
                        field:"word_count",
                        title:"字数"
                    },
                    {
		            title: '操作',
		            align: 'center',
		          formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' +  '" href="javascript:void(0)" onclick="openChapterTab(\'' + row.id + '\')"><i class="fa fa-remove"></i>章节列表</a>');
                        actions.push('<a class="btn btn-success btn-xs '  + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' +  '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');

                        return actions.join('');
                    }
		        }
                ]

            };
            $.table.init(options);

    });
    function openChapterTab(book_id) {
        console.log("open chapter id:"+book_id);
        $.modal.openTab("章节",'/book/chapter?book_id='+book_id);
    }
    // get selection content
    function getSelections() {
        return $("#bootstrap-table").bootstrapTable("getSelections");
    }
</script>
</html>